/*
 * Copyright (c) 2019 Wormpex.com. All Rights Reserved.
 */

package com.sk.threndpool;



import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author ke.su date: 2019-11-07 Time: 上午10:05
 */
public class CASTest {

    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(0);

        ExecutorService executorService = Executors.newCachedThreadPool();

        for(int i = 0;i<10000;i++){
            executorService.execute(()->{
                int num = atomicInteger.updateAndGet(a->{
                    return a+1;
                });

                System.out.println(num);
            });
        }
    }

}


